public class Main {
    public static void main(String[] args) {
        CPU cpu = new CPU( 3.8,"Intel i7");
        Memory memory = new Memory(16, "DDR4");
        HardDisk hardDisk = new HardDisk("SSD",512);
        Computer computer = new Computer("Hyper", cpu, memory, hardDisk);

        computer.show();

        System.out.println();
        computer.start();
        System.out.println();
        Memory newMemory = new Memory(32, "DDR4");
        computer.upGrandeMemory(newMemory);

        System.out.println();
        computer.show();
    }
}
class CPU{
    private String model;
    private double speed;


    public CPU(double speed, String model) {
        this.speed = speed;
        this.model = model;
    }

    public void process(){
        System.out.println("CPU"+model+"正在以"+speed+"的速度处理数据");
    }

    public double getSpeed() {
        return speed;
    }

    public String getModel() {
        return model;
    }

}
class Memory{
    private int capacity;
    private String type;

    public Memory(int capacity, String sype) {
        this.capacity = capacity;
        this.type = sype;
    }

    public int getCapacity() {
        return capacity;
    }

    public String getType() {
        return type;
    }

    public void store(){
        System.out.println("已经存储"+type+"数据"+capacity);
    }

}
class HardDisk{
    private int capacity;

    public String getInterfaceType() {
        return interfaceType;
    }

    public int getCapacity() {
        return capacity;
    }

    public HardDisk(String interfaceType, int capacity) {
        this.interfaceType = interfaceType;
        this.capacity = capacity;
    }

    String interfaceType;

    public void readWrite(){
        System.out.println("硬盘 " + capacity + "GB " +
                interfaceType + " 接口正在读写数据");
    }
}
class Computer {
    private String brand;
    private CPU cpu;
    private Memory memory;
    private HardDisk hardDisk;

    public Computer() {
    }

    public Computer(String brand, CPU cpu, Memory memory, HardDisk hardDisk) {
        this.brand = brand;
        this.cpu = cpu;
        this.memory = memory;
        this.hardDisk = hardDisk;
    }

    public void start() {
        System.out.println(brand + "电脑已开机");
        cpu.process();
        memory.store();
        hardDisk.readWrite();
    }

    public void show() {
        System.out.println("品牌:" + brand);
        System.out.println("CPU 模式：" + cpu.getModel() + "\ncpu读取速度：" + cpu.getSpeed());
        System.out.println("内存空间：" + memory.getCapacity() + "\n内存类型:" + memory.getType());
        System.out.println("硬盘 接口类型：" + hardDisk.getInterfaceType() + "\n硬盘空间" + hardDisk.getCapacity());
    }

    public void upGrandeMemory(Memory newMemory){

        System.out.println(memory.getCapacity()+"Gb->"+newMemory.getCapacity()+"Gb");
        this.memory=newMemory;
        System.out.println("内存升级成功");
    }
}


//import java.util.Random;
//public class Main {
//    public static void main(String[] args) {
//        Circle circle = new Circle("绿色",2.0);
//        Memory memory=new Memory("紫色",6.0,4.0);
//        Triangle triangle=new Triangle("蓝色",3.0,4.0,5.0);
//        circle.displayInfo();
//        memory.displayInfo();
//        triangle.displayInfo();
//    }
//}
//class Shape{
//    String color;
//    public Shape (String color)
//    {
//        this.color=color;
//    }
//    public Shape(){
//        this.color="白色";
//    }
//    public double getArea(){
//        return 0;
//    }
//    public double getPerimeter(){
//        return 0;
//    }
//    public void displayInfo(){
//        System.out.println("颜色:"+color+" "+
//                "面积"+getArea()+" "+
//                "周长"+getPerimeter());
//    }
//}
//class Circle extends Shape{
//    double radius;
//
//    public Circle(String color, double radius) {
//        super(color);
//        this.radius = radius;
//    }
//
//    public Circle(double radius) {
//        this.radius = radius;
//    }
//
//    public double getPerimeter(){
//        return 2*Math.PI*radius;
//    }
//    public double getArea(){
//        return Math.PI*radius*radius;
//    }
//}
//class  Memory extends Shape{
//    double length;
//    double width;
//
//    public Memory(String color, double length, double width) {
//        super(color);
//        this.length = length;
//        this.width = width;
//    }
//
//    public Memory() {
//        this.length = 0;
//        this.width = 0;
//    }
//
//    public double getArea(){
//        return width*length;
//    }
//
//    public double getPerimeter(){
//        return 2*(width+length);
//    }
//}
//class Triangle extends Shape{
//    double side1;
//    double side2;
//    double side3;
//
//    public Triangle(String color, double side1, double side2, double side3) {
//        super(color);
//        this.side1 = side1;
//        this.side2 = side2;
//        this.side3 = side3;
//    }
//
//    public double getPerimeter(){
//        return side1+side2+side3;
//    }
//
//    public double getArea(){
//        double s= getPerimeter()/2;
//        return Math.sqrt(s*(s-side1)*(s-side2)*(s-side3));
//    }
//
//
//}